package com.ruoyi.worker.service.impl;

import com.ruoyi.worker.domain.TermAttendanceGroup;
import com.ruoyi.worker.domain.TermAttendanceRules;
import com.ruoyi.worker.mapper.TermAttendanceGroupMapper;
import com.ruoyi.worker.service.TermAttendanceGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
public class TermAttendanceGroupServiceImpl implements  TermAttendanceGroupService  {
    @Autowired
    private TermAttendanceGroupMapper termAttendanceGroupMapper;

    @Override
    public List<TermAttendanceGroup> listTermAttendanceGroup(TermAttendanceGroup t) {
        return termAttendanceGroupMapper.listTermAttendanceGroup(t);
    }

    @Override
    public int addTermAttendanceGroup(TermAttendanceGroup t) {
        int flag =termAttendanceGroupMapper.countTermAttendanceGroup(t);
        if(flag >0 ){
           return -1;
        }
        flag =termAttendanceGroupMapper.addTermAttendanceGroup(t);
        return flag;
    }

    @Override
    public int modifTermAttendanceGroup(TermAttendanceGroup t) {
        int flag =termAttendanceGroupMapper.countTermAttendanceGroup(t);
        if(flag >0 ){
            return -1;
        }
        flag =termAttendanceGroupMapper.modifTermAttendanceGroup(t);
        return flag;
    }

    @Override
    public int delBactchTermAttendanceGroup(Long[] idList) {
        return termAttendanceGroupMapper.delBactchTermAttendanceGroup(idList);
    }

    @Override
    public TermAttendanceGroup getTermAttendanceGroup(Long id) {
        return termAttendanceGroupMapper.getTermAttendanceGroup(id);
    }

    @Override
    public int modifTermAttendanceGroupStatus(TermAttendanceGroup t) {
        return termAttendanceGroupMapper.modifTermAttendanceGroupStatus(t);
    }

    @Override
    @Transactional
    public int addTermAttendanceRules(TermAttendanceRules r) {
        termAttendanceGroupMapper.delTermAttendanceRules();
        int flag = termAttendanceGroupMapper.addTermAttendanceRules(r);
        return flag;
    }

    @Override
    public TermAttendanceRules getTermAttendanceRules() {
        return termAttendanceGroupMapper.getTermAttendanceRules();
    }
}
